package com.example.three.Controller.ShopGoodComm;


import com.example.three.DO.RecommedGood;
import com.example.three.DO.SysOfficeProdComm;
import com.example.three.DO.TableData;
import com.example.three.Service.ShopGoodComm.GoodComm;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller

@RequestMapping("")
public class ShopGoodComm {

    @Resource
    private GoodComm goodCommservice;

    @RequestMapping("To-commlist")
    public String ToRecom(){
        return "/commlist";
    }

    @RequestMapping("/commlist")
    @ResponseBody
    public TableData commlist(HttpSession session, Model model,@RequestParam Map<String, Object> params){
        List<SysOfficeProdComm> commlist = goodCommservice.commfindBy();
        String prod_name=null;
        if(params.containsKey("keyWord")){
            prod_name=params.get("keyWord").toString();
        }


        if (prod_name == null || prod_name == "") {

        }
        else {
            commlist = (List<SysOfficeProdComm>)goodCommservice.commfindBy1(prod_name);
        }
        TableData tableData = new TableData();
        tableData.setCode(0);
        tableData.setMsg("成功");
        tableData.setData(commlist);
        return tableData;

    }

    @RequestMapping("To-commlistgood")
    public String To_commlistgood(){
        return "/commlistgood";
    }

    @RequestMapping("/commlistgood")
    @ResponseBody
    public TableData commlistgood(HttpSession session, Model model,@RequestParam Map<String, Object> params){
        List<SysOfficeProdComm> commlist = goodCommservice.commfindBygood();
        String prod_name=null;
        if(params.containsKey("keyWord")){
            prod_name=params.get("keyWord").toString();
        }


        if (prod_name == null || prod_name == "") {

        }
        else {
            commlist = (List<SysOfficeProdComm>)goodCommservice.commfindBygood1(prod_name);
        }
        TableData tableData = new TableData();
        tableData.setCode(0);
        tableData.setMsg("成功");
        tableData.setData(commlist);
        return tableData;

    }



    @RequestMapping("To-commlistbad")
    public String To_commlistbad(){
        return "/commlistbad";
    }

    @RequestMapping("/commlistbad")
    @ResponseBody
    public TableData commlistbad(HttpSession session, Model model,@RequestParam Map<String, Object> params){
        List<SysOfficeProdComm> commlist = goodCommservice.commfindBybad();
        String prod_name=null;
        if(params.containsKey("keyWord")){
            prod_name=params.get("keyWord").toString();
        }


        if (prod_name == null || prod_name == "") {

        }
        else {
            commlist = (List<SysOfficeProdComm>)goodCommservice.commfindBybad1(prod_name);
        }
        TableData tableData = new TableData();
        tableData.setCode(0);
        tableData.setMsg("成功");
        tableData.setData(commlist);
        return tableData;

    }

    }

